package fr.umlv.jee.jawp.service.aws;

import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class Principal implements Serializable {

  /**
   * 
   */
  private static final long serialVersionUID = 1L;
  private static final String ITEM_ID = "0545010225";

  public static void main(String[] args) {
    Aws myAws = new Aws();

    List<Map<String, String>> articleByID = myAws.findArticleByItemID(ITEM_ID);
    List<Map<String, String>> articleByKeyword = myAws
        .findArticleByKeyword("Sarkozy");

    System.out.println("Article By ID: " + ITEM_ID);
    afficheArticle(articleByID);

    System.out.println("Article By Keyword: Sarkozy");
    afficheArticle(articleByKeyword);

  }

  public static void afficheArticle(List<Map<String, String>> listArticle) {

    int cpt = 0;
    for (Map<String, String> map : listArticle) {
      System.out.println("Produit n°: " + cpt);

      for (Iterator<String> i = map.keySet().iterator(); i.hasNext();) {
        String attributeName = i.next();
        System.out.println("\t" + attributeName + " = "
            + map.get(attributeName));
      }
      cpt++;
    }

  }
}
